package utils 
{
	/**
	 * ...
	 * @author SChabanov
	 */
	public class Validators 
	{
		
		public function Validators() 
		{
			throw new Error("static class need for text validations")
		}
		/**
		 * validate email address
		 * @param	value
		 * @return
		 */
		public static function emailValidator(value:String):Boolean
		{			
			var emailExpression:RegExp = /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})*$/;
			return emailExpression.test(value);
		}
		
		/**
		 * formats DD/MM/YY or DD/MM/YYYY or MM/DD/YY or MM/DD/YYYY
		 * @param	value
		 * @return
		 */
		public static function validateDateFormat(value:String):Boolean
		{
			var validDateRegExp:RegExp= /^(\d{1,2})\/(\d{1,2})\/(\d{2}|(19|20)\d{2})$/;
			return validDateRegExp.test(value);
		}
		/**
		 * 
		 * @param	value
		 * @return
		 */
		public static function validateURL(value:String):Boolean
		{
			var validURLRegExp:RegExp = /^http(s)?:\/\/((\d+\.\d+\.\d+\.\d+)|(([\w-]+\.)+([a-z,A-Z][\w-]*)))(:[1-9][0-9]*)?(\/([\w-.\/:%+@&=]+[\w- .\/?:%+@&=]*)?)?(#(.*))?$/i;
			return  validURLRegExp.test(value);
		}
		
		/**
		 * The password must contain one lowercase letter, one uppercase letter, one number, and be at least 6 characters long.
		 * @param	value
		 * @return
		 */
		public static function validateStrongPassword(value:String):Boolean
		{
			var validPasswordRegExp:RegExp= /^(?=^.{6,}$)((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.*$/;
			return validPasswordRegExp.test(value);
		}
		
	}

}